package org.zfes.snowier.common.monitor.jvm.server;

import org.zfes.snowier.common.monitor.utils.Arith;

/**
 * 內存相关信息
 * 
 * @author ruoyi
 */
public class Mem {
	/**
	 * 内存总量
	 */
	private String total;

	/**
	 * 已用内存
	 */
	private String used;

	/**
	 * 剩余内存
	 */
	private String free;
	
	private String usage;
	
	
	public String getTotal() {
		return String.valueOf(Arith.div(Double.valueOf(total) , (1024 * 1024 * 1024), 2));
	}

	public void setTotal(String total) {
		this.total = total;
	}

	public String getUsed() {
		return String.valueOf(Arith.div(Double.valueOf(used), (1024 * 1024 * 1024), 2));
	}

	public void setUsed(String used) {
		this.used = used;
	}

	public String getFree() {
		return String.valueOf(Arith.div(Double.valueOf(free), (1024 * 1024 * 1024), 2));
	}

	public void setFree(String free) {
		this.free = free;
	}

	public String getUsage() {
		return String.valueOf(Arith.mul(Arith.div(Double.valueOf(used), Double.valueOf(total), 4), 100));
	}

	public void setUsage(String usage) {
		this.usage =  usage;//String.valueOf(Arith.mul(Arith.div(Double.valueOf(used), Double.valueOf(total), 4), 100));
	}

	@Override
	public String toString() {
		return "Mem [total=" + total + ", used=" + used + ", free=" + free
				+ "]";
	}
	
	
}
